BioJulia系列-BGZFStream

原文戳我

  • 支持多线程的BGZF格式压缩/解压 (BGZF的spec参考这里)

  • 封装成一个IO类型, 支持IO相关操作

julia

# 启动Julia时设置多线程:
# JULIA_NUM_THREADS=2 julia -q
using BGZFStreams

# The first argument is a filename or an IO object (e.g. IOStream).
stream = BGZFStream("data.bgz")

# BGZFStream is a subtype of IO and works like a usual IO object.
while !eof(stream)
    byte = read(stream, UInt8)
    # do something...
end

# BGZFStream is also seekable with a VirtualOffset.
seek(stream, VirtualOffset(0, 2))

# The current virtual file offset is available.
virtualoffset(stream)
close(stream)

julia
Hack 建议使用TranscodingStreams.jlCodecBGZF.jl, 比这个包更快且更好跟Automa整合。